package com.clps.test;

public class Rectangle {
    private double width;
    private double height;

    // 构造函数初始化width和height
    public Rectangle(double width, double height) {
        this.width = width;
        this.height = height;
    }

    // 获取width
    public double getWidth() {
        return width;
    }

    // 设置width
    public void setWidth(double width) {
        this.width = width;
    }

    // 获取height
    public double getHeight() {
        return height;
    }

    // 设置height
    public void setHeight(double height) {
        this.height = height;
    }

    // 计算并返回周长
    public double getPerimeter() {
        return 2 * (width + height);
    }

    // 计算并返回面积
    public double getArea() {
        return width * height;
    }

    // 测试程序
    public static void main(String[] args) {
        // 创建Rectangle对象
        Rectangle rect = new Rectangle(5.0, 10.0);

        // 输出周长和面积
        System.out.println("Perimeter: " + rect.getPerimeter());
        System.out.println("Area: " + rect.getArea());
    }
}
